package com.jumper.property.comparer.demo.service.impl;


import com.jumper.property.comparer.demo.converter.OrderConverter;
import com.jumper.property.comparer.demo.entity.GoodsOrder;
import com.jumper.property.comparer.demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class OrderServiceImpl implements OrderService {

    private final Map<String, GoodsOrder> orderMap = new HashMap<>();

    @Autowired
    private OrderConverter converter;

    @Override
    public void createOrder(GoodsOrder goodsOrder) {
        orderMap.put(goodsOrder.getOrderNo(), converter.convert(goodsOrder));
    }

    @Override
    public GoodsOrder getOrder(String orderNum) {
        return orderMap.get(orderNum);
    }

    @Override
    public void updateOrder(GoodsOrder order) {
        orderMap.put(order.getOrderNo(), converter.convert(order));
    }
}
